package com.dfbz.demo01;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo01_字符串拼接性能对比 {
    public static void main(String[] args) {
        long startTime = new Date().getTime();

        String str = "";
        for (int i = 0; i < 100000; i++) {
            str += i;
        }

        long endTime = new Date().getTime();

        System.out.println((endTime - startTime));
    }


    public static void stringBuilderAppend(String[] args) {
        long startTime = new Date().getTime();

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < 1000000; i++) {
            sb.append(i);
        }

        long endTime = new Date().getTime();

        System.out.println((endTime - startTime));
    }
}
